A Pie chart that retrieves JSON data via AJAX
This goes in the documents header:
<script src="RGraph.common.core.js"></script>
<script src="RGraph.common.dynamic.js"></script>
<script src="RGraph.common.tooltips.js"></script>
<script src="RGraph.common.effects.js"></script>
<script src="RGraph.pie.js"></script>
Put this where you want the chart to show up:
<canvas id="cvs" width="450" height="350">
[No canvas support]
</canvas>
This is the code that generates the chart:
<script>
RGraph.AJAX.getJSON('/getdata.html?json', function (json)
{
var pie = new RGraph.Pie({
id: 'cvs',
data: json.data,
options: {
tooltips: json.labels,
shadow: false,
key: json.labels,
keyPositionGraphBoxed: false,
colors: ['red','gray','#afa','blue','pink','yellow','black','orange','cyan','purple'],
centerx: 175,
textAccessible: true
}
}).draw();
});
</script>